package com.frejoys.common.util;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import com.frejoys.common.config.ValueConfig;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 阿里云短信
 */
@Component
@RequiredArgsConstructor
public class SmsUtil {

    public final ValueConfig valueConfig;

    public static Client client;


    @PostConstruct
    private void init() {

        try {
            client =  new Client(new Config().setAccessKeyId(valueConfig.getAliSmsAccessKeyId()).setAccessKeySecret(valueConfig.getAliSmsAccessKeySecret()).setEndpoint(valueConfig.getAliSmsEndpoint()));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
